package com.heima.search.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.search.dto.ApArticleSearchDto;
import com.heima.search.service.IApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : wuqiang
 * @date : 2022年10月23日
 */
@RestController
@RequestMapping("/api/v1/history")
public class ApUserSearchController {

    @Autowired
    private IApUserSearchService apUserSearchService;

    /**
     * 加载当前用户搜索历史
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/load")
    public ResponseResult loadHistory(@RequestBody ApArticleSearchDto dto) {
        return apUserSearchService.loadHistory(dto);
    }

    /**
     * 删除当前用户搜索历记录
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/del")
    public ResponseResult delHistory(@RequestBody ApArticleSearchDto dto) {
        return apUserSearchService.delHistory(dto);
    }
}
